@extends('layouts.admin')
@section('title') @parent 修改文章 @stop
@section('page_title')@parent
修改文章
@show
@section('breadcrumb')@parent
{{ Breadcrumbs::render('article-edit') }}
@show
@section('content')
<div class="row">
		@include('widgets.notification')
		<div class="col-md-12">
				<!-- general form elements -->
				<div class="box box-primary">
						<div class="box-header">
								<h3 class="box-title">修改文章</h3>
						</div>
				@include('widgets.notification')
						<form for="form" class="" autocomplete="off" method="post" action="{{ route('admin.article.update', $article->id) }}" enctype="multipart/form-data" id="form-coupon">
						<input type="hidden" name="_token" value="{{ csrf_token() }}" />
						<div class="box-body">
								<div class="form-group">
										<label for="class">文章类型</label>
										{{ Form::select('class', $article_class_list, $article->class, array('id'=>'class')) }}
								</div>
								<div class="form-group" style="@if($article->down_group)display:block; @else display:none; @endif" id="down">
										<label for="class">下载类型</label>
										{{ Form::select('down_group', $down_group_list, $article->down_group) }}
								</div>
								<div class="form-group" style="display:none;" id="law_cat_list_form_group">
										<label for="class">法律类型</label>
										{{ Form::select('law_cat', $law_cat_list, $article->law_cat, array('id'=>'law_cat_list')) }}
								</div>
								<div class="form-group" style="display:none;" id="type_instrument_list_form_group">
										<label for="class">法律类型</label>
										{{ Form::select('law_cat', $type_instrument_list, $article->law_cat, array('id'=>'type_instrument_list')) }}
								</div>
								<div class="form-group">
										<label for="title">文章标题</label>
										<input name="title" id="title" class="form-control" placeholder="文章标题" value="@if(Input::old('title')){{ Input::old('article_title') }}@else{{ $article->title }}@endif" required>
										{{ $errors->first('title', '<strong class="error">:message</strong>') }}
								</div>
								<div class="form-group">
										<label for="keys">关键字</label>
										<input name="keys" id="keys" class="form-control" placeholder="多个关键字用英文半角逗号隔开" value="@if(Input::old('keys')){{ Input::old('keys') }}@else{{ $article->keys }}@endif" required>
										{{ $errors->first('keys', '<strong class="error">:message</strong>') }}
								</div>
								<div class="form-group">
										<label for="info">文章简介</label>
										<textarea cols="80" rows="10" name="info" id="info" class="form-control">@if(Input::old('info')){{ Input::old('info') }}@else{{ $article->info }}@endif</textarea>
								</div>
								<div class="form-group">
										<label for="content">文章内容</label>
										<textarea cols="80" rows="10" name="content" id="content" style="visibility: hidden; display: none;" class="form-control">@if(Input::old('content')){{ Input::old('content') }}@else{{ $article->articleContent() }}@endif</textarea>
								</div>
								<div class="form-group">
										<label>缩略图</label>
										<div class="controls">
											<div class="input-group">
												 <input class="input-file" name="img" type="file">
											</div>
										</div>
										@if($article->img)<img src="{{ $article->img }}" style="width:200px;">@endif
								</div>
								<div class="form-group">
										<label>下载文件</label>
										<div class="controls">
											<div class="input-group">
												 <input class="input-file" name="article_file" type="file">
											</div>
										</div>
										@if($article->file_path)<a href="{{ $article->file_path }}">下载文件</a>@endif
								</div>								
						</div>
						<div class="box-footer">
								<a href="{{ route('admin.article.index') }}" class="btn btn-default btn-save">返 回</a>
								@if(!$article->status)<a href="#" type="button" class="btn btn-primary btn-approve">审核通过</a>@endif
								<button type="submit" class="btn btn-primary btn-save">保 存</button>
						</div>
						</form>
				</div>
		</div>
</div>
@stop
@section('end')
    @parent
{{ HTML::script("/js/jquery-ui-1.11.1.min.js") }}
{{ HTML::script("/ckeditor/ckeditor.js") }}
<script>
$(function() {
			CKEDITOR.replace('content'	, {
						height: 250,
						extraPlugins: 'colorbutton,colordialog',
						filebrowserBrowseUrl : '/ckfinder/ckfinder.html',
						filebrowserImageBrowseUrl : '/ckfinder/ckfinder.html?Type=Images',
						filebrowserFlashBrowseUrl : '/ckfinder/ckfinder.html?Type=Flash',
						filebrowserUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
						filebrowserImageUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
						filebrowserFlashUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
			});

			$('#class').on('change', function(){
				if($(this).val() == 374)
				{
					$('#down').show();
					$('#law_cat_list_form_group').hide();
					$('#law_cat_list').prop('disabled', true);
					$('#type_instrument_list_form_group').show();
					$('#type_instrument_list').prop('disabled', false);
				} else {
					$('#down').hide();
					$('#law_cat_list_form_group').show();
					$('#law_cat_list').prop('disabled', false);
					$('#type_instrument_list_form_group').hide();
					$('#type_instrument_list').prop('disabled', true);
				}
			})

			if ($('#class').val() == 374) {
				$('#down').show();
				$('#law_cat_list').prop('disabled', true);
				$('#law_cat_list_form_group').hide();
				$('#type_instrument_list_form_group').show();
				$('#type_instrument_list').prop('disabled', false);
			} else {
				$('#down').hide();
				$('#law_cat_list_form_group').show();
				$('#law_cat_list').prop('disabled', false);
				$('#type_instrument_list_form_group').hide();
				$('#type_instrument_list').prop('disabled', true);
			}
});
$(function() {
		$(".btn-approve").click(function(){
			if(confirm("确认这篇文章通过审核？"))
			{
					location.href="{{ route('admin.article.approve', $article->id) }}";
			}
	  })
});
</script>
@stop